#include<bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f
#define cmin(a,b) a=min(a,b)
#define cmax(a,b) b=max(a,b)
#define rst(a,b) memset(a,b,sizeof(a))
#define ls p<<1
#define rs p<<1|1
#define lowbit(x) ((x)&-(x))

using namespace std;

const int N(1e5+5);

struct BIT{
    int n,a[N];
    void init(int x){
        n=x;
        for(int i=1;i<=n;i++) a[i]=inf;
    }
    void upd(int x,int v){
        for(int i=x;i;i-=lowbit(i)){
            cmin(a[i],v);
        }
    }
    int query(int x){
        if(!x) return 0;
        int res=inf;
        for(int i=x;i<=n;i+=lowbit(i)){
            cmin(res,a[i]);
        }
        return res;
    }
}dp;

int n,m,L,V,p[N];

struct car{
    int d,v,a;
}c[N];

struct node{
    int l,r;
}s[N],Q[N];

void solve(){
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++){
        cin>>c[i].d>>c[i].v>>c[i].a;
    }
    for(int i=1;i<=m;i++){
        cin>>p[i];
    }
    int tot=0,cnt=0;
    for(int i=1;i<=n;i++){
        int d=c[i].d,v=c[i].v,a=c[i].a;
        auto check=[&](int x){
            if(v*v+2*a*(x-d)>V*V) return 1;
            return 0;
        };
        if(a<=0){
            int l=d,r=L,res=0;
            while(l<=r){
                int mid=l+r>>1;
                if(check(mid)) res=mid,l=mid+1;
                else r=mid-1;
            }
            if(!res) continue;
            l=lower_bound(p+1,p+m+1,d)-p,r=upper_bound(p+1,p+m+1,res)-p-1;
            if(l>r) continue;
            s[++tot]={l,r};
        }else{
            int l=d,r=L,res=0;
            while(l<=r){
                int mid=l+r>>1;
                if(check(mid)) res=mid,r=mid-1;
                else l=mid+1;
            }
            if(!res) continue;
            l=lower_bound(p+1,p+m+1,res)-p;
            if(l>m) continue;
            s[++tot]={l,m};
        }
    }
    sort(s+1,s+tot+1,[&](node x,node y){
        if(x.l==y.l) return x.r>y.r;
        return x.l<y.l;
    });
    for(int i=1;i<=tot;i++){
        while(Q[cnt].r>=s[i].r) cnt--;
        Q[++cnt]=s[i];
    }
    dp.init(cnt);
    int l=1,r=0;
    for(int i=1;i<=m;i++){
        while(l<=cnt&&Q[l].r<i) l++;
        while(r<cnt&&Q[r+1].l<=i) r++;
        if(l<=r) dp.upd(r,dp.query(l-1)+1);
    }
    cout<<tot<<' '<<m-dp.query(cnt)<<'\n';
}

signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;cin>>t;
    while(t--) solve();

    return 0;
}